
<template>
  <view class="container">
    <Navbar showNavbar title="跑腿服务"/>
    <!-- 搜索区域 -->
    <view class="search-box">
      <image style="width: 40rpx;height: 40rpx" src="/static/home/search.png"></image>
      <text class="placeholder">请输入服务项目</text>
    </view>

    <!-- 轮播图区域 -->
    <swiper class="banner-box" circular autoplay interval="3000" duration="500">
      <swiper-item v-for="(item, index) in bannerList" :key="index">
        <image class="banner-image" :src="item.image" mode="aspectFill"/>
      </swiper-item>
    </swiper>

    <!-- 热点资讯 -->
    <view class="news-box">
      <image style="width: 118rpx;height: 36rpx;flex-shrink: 0;margin-right: 12rpx" src="/static/home/hot_icon.png"></image>
      <swiper class="news-swiper" vertical circular autoplay :interval="3000" :duration="500">
        <swiper-item>
          <view class="news-text">随着生活节奏的加快，汉中市居民对于便捷购物和即时服务的需求日益增长。特别是在电商和即时配送服务的推动下，居民对于“最后一公里”配送服务的需求愈发迫切。据洞察研报市场调研数据显示，汉中市的跑腿服务需求在过去三年内增长了近50%，且这一趋势仍在持续上升。分分钟平台正是基于这一市场需求，旨在为汉中市居民提供更加便捷、高效的本地服务。
          </view>
        </swiper-item>
        <swiper-item>
          <view class="news-text">在订单高峰期，平台会为跑腿员提供额外的补贴，以鼓励其接单并快速完成配送。
            满单奖励：跑腿员在达到一定订单量后，可能会获得额外的满单奖励。这有助于激励跑腿员提高工作效率和服务质量</view>
        </swiper-item>
      </swiper>
    </view>

    <!-- 功能区域 -->
    <view class="grid-box">
      <view class="grid-item" @click="toPage(item)" v-for="(item, index) in gridList" :key="index">
        <image class="grid-icon" :src="item.image" mode="aspectFill" />
        <text class="grid-text">{{ item.name }}</text>
      </view>
    </view>

    <view class="tab-box">
      <u-tabs
        :list="tabsList"
        @change="tabsClick"
        :current="current"
        lineColor="#1A8DFF"
        :activeStyle="{
          color: '#333333',
          fontWeight: 'bold',
          fontSize: '36rpx'
        }"
        :inactiveStyle="{
          color: '#333333',
          fontWeight: 'normal',
          fontSize: '36rpx'
        }"
        bgColor="transparent"
      ></u-tabs>
    </view>
  </view>
</template>

<script>
import { Swiper, SwiperItem } from '@dcloudio/uni-ui';
import Navbar from "../../components/navbar.vue";
export default {
  name: "index",
  components: {
    Navbar,
    'u-tabs': () => import('uview-ui/components/u-tabs/u-tabs')
  },
  data() {
    return {
      gridList: [

      ],
      bannerList: [
      ],
      tabsList: [
        { name: '随手捎' },
        { name: '1小时达' }
      ],
      current: 0,
      houseList: [
        {
          image: 'https://ai-public.mastergo.com/ai/img_res/faab719d2878fdd524b6bb067c841acf.jpg',
          title: '河东大厦精装修带家具170平',
          location: '长江路',
          area: '248',
          type: '精装修',
          price: '5000',
          unitPrice: '5000'
        },
        {
          image: 'https://ai-public.mastergo.com/ai/img_res/d083e6080227fed9a632b570a9a4cefb.jpg',
          title: '河东大厦精装修带家具170平',
          location: '长江路',
          area: '248',
          type: '精装修',
          price: '5000',
          unitPrice: '5000'
        }
      ]
    }
  },
  methods: {
    tabsClick(index) {
      console.log('Tab clicked:', index)
      this.current = index;
      // TODO: Add logic to load different content based on selected tab
    },
    toPage(item) {
      uni.navigateTo({
        url: item.url
      })
    }
  },
  onLoad() {
    this.$api.getWxMenuList().then(res => {
      this.gridList = res
    })
    this.$api.getWxBannerList().then(res => {
      this.bannerList = res
    })
  }
}
</script>

<style>
page {
  height: 100%;
  overflow: auto;
  padding-bottom: 120rpx;
}

.container {
  padding: 0 30rpx;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: linear-gradient( 180deg, #E4F6FF 0%, #F7F8FA 100%);
}

.search-box {
  display: flex;
  align-items: center;
  height: 72rpx;
  background-color: #FFFFFF;
  border-radius: 36rpx;
  padding: 0 24rpx;
  margin: 24rpx 0;
}

.placeholder {
  margin-left: 16rpx;
  font-size: 14px;
  color: #999999;
}

.banner-box {
  width: 100%;
  height: 280rpx;
  border-radius: 16rpx;
  overflow: hidden;
  margin-bottom: 24rpx;
}

.banner-image {
  width: 100%;
  height: 100%;
}

.banner-content {
  position: absolute;
  top: 48rpx;
  left: 48rpx;
  color: #FFFFFF;
}

.banner-title {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 16rpx;
  display: block;
}

.banner-subtitle {
  font-size: 14px;
  margin-bottom: 24rpx;
  display: block;
}

.banner-button {
  display: inline-block;
  padding: 12rpx 32rpx;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 24rpx;
  font-size: 14px;
}

.news-box {
  display: flex;
  align-items: center;
  //background-color: #ffffff;

  padding:12rpx 0;
  border-radius: 12rpx;
  margin-bottom: 24rpx;
}

.news-swiper {
  flex: 1;
  height: 40rpx;
}

.news-text {
  margin-left: 16rpx;
  font-size: 14px;
  color: #666666;
  line-height: 40rpx;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.grid-box {
  display: flex;
  flex-wrap: wrap;
  background-color: #F7F8FA;
  border-radius: 12rpx;
  padding: 24rpx 0;
}

.grid-item {
  width: 25%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24rpx;
}

.grid-icon {
  width: 92rpx;
  height: 92rpx;
}

.grid-text {
  font-size: 26rpx;
  color: #333333;
}

.tab-box {
  display: flex;
  margin-bottom: 24rpx;
}

.tab-item {
  font-size: 16px;
  color: #999999;
  margin-right: 48rpx;
}

.tab-item.active {
  color: #333333;
  font-weight: bold;
  position: relative;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -8rpx;
  left: 0;
  width: 100%;
  height: 4rpx;
  background-color: #1890FF;
  border-radius: 2rpx;
}
.house-item {
  background-color: #FFFFFF;
  border-radius: 12rpx;
  padding: 24rpx;
  margin-bottom: 24rpx;
  display: flex;
}

.house-image {
  width: 240rpx;
  height: 180rpx;
  border-radius: 12rpx;
  margin-right: 32rpx;
  flex-shrink: 0;
}

.house-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.house-title {
  font-size: 32rpx;
  color: #333333;
  font-weight: bold;
  margin-bottom: 12rpx;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.house-detail {
  display: flex;
  align-items: center;
  margin-bottom: 12rpx;
}

.location, .area, .type {
  font-size: 14px;
  color: #666666;
}
.line {
  height: 20rpx;
  width: 2rpx;
  background-color: #DCDCDC;
  margin: 0 24rpx;
}
.house-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.price {
  font-size: 20px;
  color: #FF6B6B;
  font-weight: bold;
}

.unit {
  font-size: 14px;
  color: #FF6B6B;
  margin-left: 4rpx;
}

.unit-price {
  font-size: 14px;
  color: #999999;
  margin-left: 24rpx;
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100rpx;
  background-color: #FFFFFF;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #EEEEEE;
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab-bar-item text {
  font-size: 12px;
  color: #999999;
  margin-top: 4rpx;
}

.tab-bar-item.active text {
  color: #1890FF;
}
</style>
